﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/pages/safeai/jsp/common/taglibs.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新增优惠卷菜单</title>
<link href="css/together.css" rel="stylesheet" type="text/css" />
<link type="text/css" rel="StyleSheet" media="all" href="${ctx}/css/combined.css">
<link type="text/css" rel="StyleSheet" media="all" href="${ctx}/css/global.css">
<link href="${ctx}/css/jquery.popup.css" rel="stylesheet" type="text/css">
<link href="${ctx}/css/jquery.treeview.css" rel="stylesheet" type="text/css">
<link href="${ctx}/css/safeai/together.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="${ctx}/js/calendar.js"></script>
<script type="text/javascript" src="${ctx}/js/calendar-zh.js"></script>
<script type="text/javascript" src="${ctx}/js/calendar-setup.js"></script>
<script language="javascript" src="${ctx}/script/common/jquery.js"></script>
<script language="javascript" src="${ctx}/script/common/jquery.treeview.js"></script>
<script language="javascript" src="${ctx}/script/common/jquery.cookie.js"></script>
<script language="javascript" src="${ctx}/script/common/jquery.dimensions.js"></script>
<script language="javascript" src="${ctx}/script/common/jquery.popup.js"></script>
<script type="text/javascript" src="${ctx}/script/product/catalog.js"></script>
<script type="text/javascript" src="${ctx}/dwr/interface/catalogHelper.js"></script>
<script type='text/javascript' src='${ctx}/dwr/interface/filterService.js'></script>
<script type='text/javascript' src='${ctx}/dwr/interface/productService.js'></script>
<script type='text/javascript' src='${ctx}/dwr/engine.js'></script>
<script type="text/javascript" src="${ctx}/script/common/common.js"></script>
<script type="text/javascript" src="${ctx}/script/product/product.js"></script>
<script type="text/javascript">
     $(document).ready(function(){
			jQuery(function($){
				    $("input#catalog").popup(builderTreeTag(2));
				    $(".treeview-popup").treeview({ 
			        persist: "cookie",
			        cookieId: "treeview-popup"
		        });
			    });
  	$("ul.treeview-popup li>a").click(function(){
  		document.getElementById("catalogId").value = this.id;
	  });
	})
 
    // Hack to avoid bug in jscalendar - JRA-7713
    if (!Calendar._TT["WEEKEND"]) Calendar._TT["WEEKEND"] = "0,6";
    if (!Calendar._TT["DAY_FIRST"]) Calendar._TT["DAY_FIRST"] = "Display %s first";
    function chen1(){
    	var dingdanjine = document.getElementById("dingdanjine").value;
    	var youjine = document.getElementById("youjine").value;
    	var youshi = document.getElementById("youshi").value;
    	var youzhang = document.getElementById("youzhang").value;
    	
    	var start = document.getElementById("created:start").value;
    	var after = document.getElementById("created:after").value;
    		
    	if(parseInt(dingdanjine)<=parseInt(youjine)){
    		alert("订单金额下限要大于优惠券金额");
    		return false;
    	}
    	if(start==""||after==""){
    		alert("日期格式错误");
    		return false;
		}
    	var zhengze = /^[0-9]*$/;
    	if(!zhengze.exec(dingdanjine)||!zhengze.exec(youjine)||!zhengze.exec(youshi)||!zhengze.exec(youzhang)){
    		alert("格式错误");
    		return false;
		}
		
		document.getElementById("ecouponForm").submit();
    }
</script>
</head>

<body>
<html:form action="/ecoupon" method="post">
<input type="hidden" name="method" value="insert"/>
<table align="center" width="98%">
	<tr>
    	<th colspan="4" height="25px">新增优惠信息</th>
    </tr>
    <tr>
    	<td class="td_01" nowrap>优惠名称：</td>
      	<td class="td_04">
        	<input type="text" name="ecoupon.name" size="20px" id="textfield" maxlength="20" />        </td>
        <td class="td_01" nowrap>状态：</td>
      <td class="td_04">
      	<select name="ecoupon.struts" id="select"> 
          <option value="0">有效</option>
          <option value="1">无效</option>
        </select>      </td>
    </tr>
    <tr>
    	<td class="td_01" nowrap>生效日期：</td>
      	<td class="td_04">
      		<input name="ecoupon.startimeStr" id="created:start" value="${ecoupon.addtimeStr}"  type="text" / style="background-image:url(${ctx}/images/cal.gif); background-repeat:no-repeat; background-position:left;padding-left:25px; cursor:hand;width:176px"> 
			<script type="text/javascript">
		    	Calendar.setup({
		
		        firstDay       :    0,                  // first day of the week
		        inputField     :    "created:start",     // id of the input field
		        button         :    "created:start_trigger_c",  // trigger for the calendar (button ID)
		        align          :    "Bl",           // alignment (defaults to "Bl")
		        singleClick    :    true,
		             ifFormat       : "%y/%m/%d"      // our date only format
		         });
            </script>
      	</td>
        <td class="td_01" nowrap>失效日期：</td>
      	<td class="td_04">
      		<input name="ecoupon.endtimeStr" id="created:after" value="${ecoupon.addtimeStr}"  type="text" / style="background-image:url(${ctx}/images/cal.gif); background-repeat:no-repeat; background-position:left;padding-left:25px; cursor:hand;width:176px"> 
			<script type="text/javascript">
		    	Calendar.setup({
		
		        firstDay       :    0,                  // first day of the week
		        inputField     :    "created:after",     // id of the input field
		        button         :    "created:after_trigger_c",  // trigger for the calendar (button ID)
		        align          :    "Bl",           // alignment (defaults to "Bl")
		        singleClick    :    true,
		             ifFormat       : "%y/%m/%d"      // our date only format
		         });
            </script>
      	</td>
  </tr>
    <tr>
    	<td class="td_01" nowrap>描述信息：</td>
     	<td colspan="3" class="td_04">
        	<textarea name="ecoupon.description" id="textarea" cols="45" rows="4"></textarea>
        </td>
    </tr>
    <tr>
    	<td class="td_01" nowrap>产品类别：</td>
      	<td class="td_04">
      		<input id="catalogId" name="ecoupon.catalogId" type="hidden"/>
      		<input id="catalog" type="text"/> 
		</td>
				
        <td class="td_01" nowrap>品&nbsp;&nbsp;牌：</td>
        <td class="td_04">
        	<%-- <input type="text" name="textfield" size="12px" id="textfield" />&nbsp;&nbsp; --%>
        	<html:select property="ecoupon.producttype">
           	  <html:option value="0">--ALL--</html:option>
           	   <html:options collection="BrandList" property="id" labelProperty="name"/>
            </html:select> 
        </td>
    </tr>
     <tr>
    	<td class="td_01" nowrap>具体产品：</td>
      	<td class="td_04">
      	<input type="hidden" name="ecoupon.productid" id="ecoupon.productid">
        <input type="text" name="product" size="12px" id="product" />&nbsp;&nbsp;
    	<input type="button" value="搜索" class="btn" onclick="window.open('${ctx}/ecoupon.do?method=search&productname='+encodeURI(document.getElementById('product').value))"/>                    
        </td>
        <td class="td_01" nowrap>订单金额下限：</td>
        <td class="td_04">
        	<input type="text" name="ecoupon.minmoney" size="20px" id="dingdanjine"/>
        </td>
    </tr>
     <tr>
    	<td class="td_01" nowrap>优惠券金额：</td>
      	<td class="td_04">
        	<input type="text" name="ecoupon.favourablemoney" size="20px" id="youjine" />
        </td>
        <td class="td_01" nowrap>允许使用次数：</td>
        <td class="td_04">
        	<input type="text" name="ecoupon.maxtimes" size="20px" id="youshi" />
        </td>
    </tr>
     <tr>
    	<td class="td_01" nowrap>优惠券张数</td>
      	<td colspan="3" class="td_04">
        	<input type="text" name="count" size="20px" id="youzhang" />
        </td>
    </tr>
    <tr>
    	<td colspan="4" align="center">
        	<input name="" value="新增优惠券" type="button" class="btn" onclick="chen1()"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input name="" value="取&nbsp;&nbsp;消" type="button" class="btn" onclick="javascript:window.location.href='${ctx}/ecoupon.do?method=query'"/>
        </td>
   	</tr>
</table>
</html:form>
</body>
</html>
